package org.simple_blogging;
import java.io.IOException;

import javax.servlet.http.*;

@SuppressWarnings("serial")
public class SaveBlog extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		resp.setContentType("text/html");
		resp.getWriter().println("ERROR 404: Page not Found!!!");
	}
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		resp.setContentType("text/html");
		
		String blogTitle = req.getParameter("blog_title");
		String blogText = req.getParameter("blog_text");
		String dateSubmitted = req.getParameter("date_submitted");
		
		BlogEntry theBlog = new BlogEntry(blogTitle, blogText, dateSubmitted);
		theBlog.addToDataStore();
		
		resp.sendRedirect("main.jsp");
	}
}